package com.handsome.组合模式;

import java.util.ArrayList;
import java.util.List;

/**
 * 学院
 * @author niechun
 * @date 2023/3/1 20:38
 */
public class College extends OrganizationComponent{
    private List<OrganizationComponent> list=new ArrayList<>();


    public College(String name, String description) {
        super(name, description);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public void setName(String name) {
        super.setName(name);
    }

    @Override
    public String getDescription() {
        return super.getDescription();
    }

    @Override
    public void setDescription(String description) {
        super.setDescription(description);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        //实际业务环境下 university类和college类的add方法业务逻辑不一定相同 所以分别建了两个类
        list.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        list.add(organizationComponent);
    }


    @Override
    public void print() {
        System.out.println("-------"+getName()+"----------");
        for (OrganizationComponent organizationComponent : list) {
            organizationComponent.print();
        }
    }
}
